<form action="" method="post">
    <input type="submit" name="sub" value="获取键名">
    <input type="submit" name="sub1" value="获取值">
</form>
<?php
/**
 * Date：2020-12-10 19:56
 * Title: 获取数组当前的键名和值
 * Description：
 * Error:
 */
$arr = array('编程'=>'123', 'soft'=>'你好', '456'=>'mingri');
if ($_POST['sub']) {
    echo "键名为：";
    foreach ($arr as $key => $value) {
        echo $key."&nbsp;&nbsp;&nbsp;&nbsp;";
    }
}
echo "<br>";
if ($_POST['sub1']) {
    echo "值为：";
    foreach ($arr as $key => $value) {
        echo $value."、";
    }
}
